package com.mysqldemo.controller;

import com.mysqldemo.entity.vo.ResponseVO;
import com.mysqldemo.entity.vo.PaginationResultVO;
import com.mysqldemo.entity.po.Record;
import com.mysqldemo.entity.query.RecordQuery;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import com.mysqldemo.service.RecordService;
import java.util.List;
/**
 * @Description 点赞记录Controller
 * @Author 徐大勇
 * @Version 1.8.0_131
 * @date 2023/07/06
 */

@RestController
@RequestMapping("/record")
public class RecordController  extends ABaseController{
	@Resource
	private RecordService recordService;
	//新增
	@RequestMapping("add")
	public ResponseVO add( Record record){
		recordService.add(record);
		return getSuccessResponseVO(null);
	}
	//根据条件分页查询
	@RequestMapping("loadDateList")
	public ResponseVO loadDateList( RecordQuery  query){
		return getSuccessResponseVO(recordService.findListByPage(query));
	}
	//批量新增
	@RequestMapping("addBatch")
	public ResponseVO addBatch(@RequestBody List<Record> listBatch){
		recordService.addBatch(listBatch);
		return getSuccessResponseVO(null);
	}
	//批量新增/更新
	@RequestMapping("addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Record> listBatch){
		recordService.addOrUpdateBatch(listBatch);
		return getSuccessResponseVO(null);
	}

	//通过OpType查询
	@RequestMapping("getOpType")
	public ResponseVO getOpType(  Integer opType) {
		return getSuccessResponseVO(recordService.getByOpType(opType));
	}

	//通过OpType修改
	@RequestMapping("updateOpType")
	public ResponseVO updateOpType( Record bean , Integer opType) {
		recordService.updateByOpType(bean,opType);
		return getSuccessResponseVO(null);
	}

	//通过OpType删除
	@RequestMapping("deleteOpType")
	public ResponseVO deleteOpType(Integer opType) {
		recordService.deleteByOpType(opType);
		return getSuccessResponseVO(null);
	}


	//通过OpId查询
	@RequestMapping("getOpId")
	public ResponseVO getOpId(  Integer opId) {
		return getSuccessResponseVO(recordService.getByOpId(opId));
	}

	//通过OpId修改
	@RequestMapping("updateOpId")
	public ResponseVO updateOpId( Record bean , Integer opId) {
		recordService.updateByOpId(bean,opId);
		return getSuccessResponseVO(null);
	}

	//通过OpId删除
	@RequestMapping("deleteOpId")
	public ResponseVO deleteOpId(Integer opId) {
		recordService.deleteByOpId(opId);
		return getSuccessResponseVO(null);
	}

}
